﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using AppSettingsLib;

namespace Setup
{
    public partial class SetupForm : Form
    {
        AppSettingsManager Settings = new AppSettingsManager();

        public SetupForm()
        {
            InitializeComponent();
        }

        private void SetupVideoPlayer_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();

                //ofd.InitialDirectory = AppSetup.Instance.VideoPlayerLoacationDefault;
                ofd.InitialDirectory = Settings.UserSettings.VideoPlayerLocationDefault;

                ofd.Filter = "Application files|*.exe|All files |*.*";
                ofd.FilterIndex = 1;
                ofd.RestoreDirectory = true;

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    //SelectedMoviePlayer.Text = AppSetup.Instance.VideoPlayer = ofd.FileName;
                    SelectedMoviePlayer.Text = Settings.UserSettings.VideoPlayer = ofd.FileName;

                    //AppSetup.Instance.VideoPlayerLoacationDefault = Path.GetDirectoryName(ofd.FileName);
                    Settings.UserSettings.VideoPlayerLocationDefault = Path.GetDirectoryName(ofd.FileName); 
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Setup of video player failed");
            } 
        }

        private void SetupFormClosing(object sender, FormClosingEventArgs e)
        {
            //AppSetup.Instance.Save();
            Settings.UserSettings.Save();
        }
    }
}
